package com.arges.web.common;

import java.util.ArrayList;
import java.util.List;

public class QueryColumn
{
	private String propertyName; // 关联属性里面的属性用 . 号分隔， 如 ChannelOrgRelation.java内查询deviceName,

	// propertyName为 device.name
	private String propertyAlias; // 属性的别名，即如果将查询结果转化为bean时，对应到bean内的属性，如果该值为空，

	// 则默认对应到propertyName最后一个 . 后面的字符串 所表示的属性名
	// 如device.name, 对应的别名为 name（即bean内必须要有 name属性)

	public QueryColumn(String propertyName)
	{
		this.propertyName = propertyName;
	}

	public QueryColumn(String propertyName, String propertyAlias)
	{
		this.propertyName = propertyName;
		this.propertyAlias = propertyAlias;
	}

	public String getPropertyName()
	{
		return propertyName;
	}

	public void setPropertyName(String propertyName)
	{
		this.propertyName = propertyName;
	}

	public String getPropertyAlias()
	{
		return propertyAlias;
	}

	public void setPropertyAlias(String propertyAlias)
	{
		this.propertyAlias = propertyAlias;
	}

	public String toString()
	{
		return this.propertyName + " : " + this.propertyAlias;
	}

	public static List<QueryColumn> asList(String... propertyNames)
	{
		List<QueryColumn> queryCols = new ArrayList<QueryColumn>();
		for (String propertyName : propertyNames)
		{
			queryCols.add(new QueryColumn(propertyName));
		}
		return queryCols;
	}
}
